CC := gcc

log := thirdparty/log/log.h thirdparty/log/log.c
#$^表所有创建目标文件需要的依赖文件
#$@表示log_test(被编译的目标)
log_test: test/log_test.c $(log)
	-$(CC) $^ -o $@ -Ithirdparty   
	-./$@
	-rm $@

cJSON :=thirdparty/cJSON/cJSON.h thirdparty/cJSON/cJSON.c
cJSON_test: test/cJSON_test.c $(cJSON) $(log)
	-$(CC) $^ -o $@ -Ithirdparty
	-./$@
	-rm $@

app_common :=app/app_common.h app/app_common.c
app_common_test: test/app_common_test.c $(app_common) $(log)
	-$(CC) $^ -o $@ -Iapp -Ithirdparty
	-./$@
	-rm $@

app_message :=app/app_message.h app/app_message.c
app_message_test: test/app_message_test.c $(app_message) $(app_common) $(log) $(cJSON)
	-gcc $^ -o $@ -Iapp -Ithirdparty
	-./$@
	-rm $@


mqtt_test: test/mqtt_test.c
	-$(CC) $^ -o $@ -lpaho-mqtt3c
	-./$@
	-rm $@

app_mqtt:=app/app_mqtt.h app/app_mqtt.c
app_mqtt_test: test/app_mqtt_test.c $(app_mqtt) $(log)
	-$(CC) $^ -o $@ -lpaho-mqtt3c -Iapp -Ithirdparty
	-./$@
	-rm $@

app_pool:=app/app_pool.h app/app_pool.c
app_pool_test: test/app_pool_test.c $(app_pool) $(log)
	-$(CC) $^ -o $@ -Iapp -Ithirdparty  -lrt
	-./$@
	-rm $@

app_buffer:=app/app_buffer.h app/app_buffer.c
app_buffer_test: test/app_buffer_test.c $(app_buffer) $(log)
	-$(CC) $^ -o $@ -Iapp -Ithirdparty
	-./$@
	-rm $@

app_device:=app/app_device.c app/app_device.h
app_device_test: test/app_device_test.c $(app_device) $(log) $(app_buffer) $(app_message) $(app_common) $(cJSON) $(app_pool) $(app_mqtt) 
	-$(CC) -o $@ $^ -Ithirdparty -Iapp -lpaho-mqtt3c -lrt -pthread
	-./app_device_test
	-rm app_device_test